﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Kenly.ChineseSegment.Core
{
    /// <summary>
    /// 重复分词过滤器。
    /// </summary>
    public static class SegmentFilter
    {
        /// <summary>
        /// 过滤掉重复的分词。
        /// </summary>
        /// <param name="segmentList"></param>
        public static void Filter(List<string> segmentList)
        {
            if (segmentList == null || segmentList.Count <= 0)
            {
                return;
            }

            segmentList.Sort();

            for(int i=segmentList.Count-1;i>1;i--)
            {
                if (segmentList[i] == segmentList[i - 1])
                {
                    segmentList.RemoveAt(i);
                }
            }
        }
    }
}
